package cn.wolfcode.util;

import cn.wolfcode.domain.Employee;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpSession;
import java.util.List;

public abstract class UserContext {
/*

    public static final String EMPLOYEE_IN_SESSION="EMPLOYEE_IN_SESSION";
    public static final String PERMISSION_IN_SESSION="PERMISSION_IN_SESSION";

    */
/**
     * 获取session对象
     * @return
     *//*

    public static  HttpSession getSession(){
        //利用springMVC的工具类RequestContextHolder来获取session对象
        ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return attrs.getRequest().getSession();
    }

    */
/**
     * 将当前登录用户存入session中
     * @param employee
     *//*

    public static void setCurrentUser(Employee employee) {
        getSession().setAttribute(EMPLOYEE_IN_SESSION,employee);
    }

    */
/**
     * 从session中获取当前登录用户
     * @return
     *//*

    public static Employee getCurrentUser() {
        return (Employee) getSession().getAttribute(EMPLOYEE_IN_SESSION);
    }

    */
/**
     * 将当前用户所拥有的权限存入到session中
     * @param permissions
     *//*

    public static void setPermission(List<String> permissions) {
        getSession().setAttribute(PERMISSION_IN_SESSION,permissions);
    }

    */
/**
     * 从session中获取当前用户所拥有的所有的权限
     * @return
     *//*

    public static List<String> getPermission() {
        return (List<String>) getSession().getAttribute(PERMISSION_IN_SESSION);
    }
*/

}
